from re import template
from django.conf import Settings, settings
from django.http.response import HttpResponseBase
from django.shortcuts import render
from django.shortcuts import HttpResponse
from  utils.tencent.sms import send_sms_single
import random
from django.conf import settings
# Create your views here.
def sms(request):
    '''发送短信
        ?tpl=login  登陆
        ?tpl=register  注册
    '''
    tpl = request.GET.get('tpl')
    template_id = settings.TENCENT_SMS_TEMPLATE.get(tpl)
    if not template_id:
        return HttpResponse('模板不存在')
    code = random.randrange(1000,9999)
    res = send_sms_single('17563222219','1249653',[code, ])
    print(res)

    if res['result'] == 0:
        return HttpResponse('成功')
    else:
        return HttpResponseBase(res['errmsg'])
def shu(request):
    g = 5 
    for  i  in range(g):
        print('*')
